package com.github.boluo1230.wechat.entity.message;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import java.io.Serializable;

@JsonInclude(JsonInclude.Include.NON_NULL)
@Getter
@Setter
@NoArgsConstructor
public class WxCustomTemplate implements WxCustomMsg, Serializable, Cloneable {
    @JsonProperty(value = "touser")
    private String toUser;

    @JsonProperty(value = "template_id")
    private String templateId;

    @JsonProperty(value = "url")
    private String url;

    @JsonProperty(value = "miniprogram")
    private MiniProgram miniProgram;

    @JsonProperty(value = "data")
    private WxCustomTemplateData data;

    public WxCustomTemplate(String toUser, String templateId, String url) {
        this.setToUser(toUser);
        this.setTemplateId(templateId);
        this.setUrl(url);
    }

    @Getter
    @Setter
    @NoArgsConstructor
    public static class MiniProgram implements Cloneable {
        @JsonProperty(value = "appid")
        private String appId;

        @JsonProperty(value = "pagepath")
        private String pagePath;

        public MiniProgram(String appId, String pagePath) {
            this.setAppId(appId);
            this.setPagePath(pagePath);
        }

        public static MiniProgram newInstance(String appId, String pagePath) {
            return new MiniProgram(appId, pagePath);
        }

        public Object clone() throws CloneNotSupportedException {
            return super.clone();
        }
    }

    public Object clone() throws CloneNotSupportedException {
        return super.clone();
    }
}
